package cn.cc.test;

public class BubbleSort {
    public static void bubbleSort(int[] a){

        int size =  a.length;
        for (int i = 0; i < a.length -1; i++) { //外城循环控制排序的次数
            for (int j = 0; j < size - i - 1;j ++ ) { //内层循环控制每次排序的次数
                int temp = 0 ;
                if (a[j] > a[j+1]){
                    temp = a[j+1];
                    a[j+1]=a[j];
                    a[j] = temp ;
                }
            }
        }
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
    }

    public static void main(String[] args) {
        int[] a = {1,23,4,52,2};
        bubbleSort(a);
    }
}
